package com.ag.lwc.action;

import java.util.List;


import com.ag.bean.TbEvent;
import com.ag.bean.TbEventInfect;
import com.ag.common.BaseAction;
import com.ag.dao.TbEventDAO;
import com.ag.lwc.service.EventInfectService;

//事件影响范围

public class EventInfectAction extends BaseAction 
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 6820534546624233719L;
	private TbEventInfect tbEventInfect;			//事件影响范围
	private List<TbEventInfect> result;
	private String message;
	private EventInfectService service;
	private TbEvent event;								//事件，从session中获取
	private TbEventDAO eventDAO;						//测试用的事件dao
	public void setEventDAO(TbEventDAO eventDAO) {
		this.eventDAO = eventDAO;
	}
	public String find()
	{
		event=this.getEvent();							//从session中获取事件事件
		result=service.find(event.getEId());
		System.out.println("*********action:******事件范围列表的长度："+result.size());
		message="findSuccess";
		return "find";
	}
	public String delete()
	{
		try
		{
			service.delete(tbEventInfect.getEiId());

			message="delete_success";
			
			
		}
		catch(Exception e)
		{
			message="删除失败";
			
		}
		return "delete";
	}
	public String save()
	{
		event=this.getEvent();						//从session中获取事件事件
		try
		{
			tbEventInfect.setTbEvent(event);
			service.save(tbEventInfect);
			message="save_success";
			
		}
		catch(Exception e)
		{
			message="保存失败: "+e.toString();
			System.out.println(message);
			
		}
		return "save";
	}
	public String modify()
	{
		event=this.getEvent();						//从session中获取事件事件
		try
		{
			tbEventInfect.setTbEvent(event);
			service.update(tbEventInfect);
			message="change_success";
		
			
		}
		catch(Exception e)
		{
			message="修改失败";
			
		}
		return "modify";
	}
	public TbEventInfect getTbEventInfect() {
		return tbEventInfect;
	}
	public void setTbEventInfect(TbEventInfect tbEventInfect) {
		this.tbEventInfect = tbEventInfect;
	}
	public List<TbEventInfect> getResult() {
		return result;
	}
	public void setResult(List<TbEventInfect> result) {
		this.result = result;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public EventInfectService getService() {
		return service;
	}
	public void setService(EventInfectService service) {
		this.service = service;
	}
	public TbEvent getEvent() {
		event = eventDAO.findById("1009181001");
		
		return event;
	}
	public void setEvent(TbEvent event) {
		this.event = event;
	}

}
